package config

import com.trjcn.wxpay.service.WXPayService
import factory.ActionFactory
import org.springframework.beans.factory.InitializingBean
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Configuration

@Configuration
class WXExamplePayProperties extends WXPayProperties with InitializingBean{

  /**
   * appid
   */
  @Value("${xxxxx}") private val appId:String = null


  /**
   * 商户号
   */
  @Value("${xxxxx}") private val mchId:String = null

  /**
   * 合作Secretkey
   */
  @Value("${xxxxx}") private val mchKey:String = null

  /**
   * 下单网关
   */
  @Value("${xxxxx}") private val gateway:String = null

  /**
   * 支付回调地址
   */
  @Value("${xxxxx}") private val notifyURL:String = null

  /**
   * 退款回调地址
   */
  @Value("${xxxxx}") private val refundNotifyURL:String = null

  /**
   * 证书绝对路径
   */
  @Value("${xxxxx}") private val certPath:String = null

  /**
   * 证书密码
   */
  @Value("${xxxxx}") private val certPassword:String = null

  override def getAppId: String = appId

  override def getMchId: String = mchId

  override def getMchKey: String = mchKey

  override def getGateway: String = gateway

  override def getNotifyURL: String = notifyURL

  override def getRefundNotifyURL: String = refundNotifyURL

  override def getCertPath: String = certPath

  override def getCertPassword: String = certPassword

  override def afterPropertiesSet(): Unit = ActionFactory.setWXPayProperties("wxExample", this)

  override def getWXPayService = new WXPayService(getGateway, getAppId, getMchKey, getMchId, getMchKey)
}
